package com.yh.dao;

import com.yh.javabean.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface PermissionDao<permission> {

    @Select("select * from permission")
    List<Permission> selectAll();

    @Insert("insert into permission (permissionName,url) values (#{permissionName},#{url})")
    int insertPermission(Permission permission);


    @Delete("delete from permission where id=#{id}")
    int deleteById(int id);

    @Update("update permission set permissionName=#{permissionName},url=#{url} where id=#{id}")
    int updatePermission(Permission permission);

    @Select("select * from permission where id=#{id}")
    Permission selectById(int id);
@Select(" select p.*\n"+"from users u, role r,permission p,users_role ur,role_permission rp\n"+"where u.id=ur.uid and r.id=ur.rid and r.id=rp.rid and p.id=rp.pid and u.id=#{uid} ")
    List<permission> selectByUid(int uid);
}
